import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace EdubaseAcademicPeriodApi {
  /** 学段类型信息 */
  export interface AcademicPeriod {
    id: number; // 主键ID
    period?: number; // 学段编码
    periodName?: string; // 学段名称
    sort?: number; // 学段顺序
    minGrade: number; // 最小年级
    maxGrade: number; // 最大年级
    status: number; // 是否启用
    metadata: string; // 学段特定参数
  }
}

/** 查询学段类型分页 */
export function getAcademicPeriodPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<EdubaseAcademicPeriodApi.AcademicPeriod>
  >('/edu/base/academic-period/page', data, { desensitize, encrypt });
}
/** 查询学段类型列表 */
export function getAcademicPeriodList() {
  return requestClient.post<EdubaseAcademicPeriodApi.AcademicPeriod[]>(
    '/edu/base/academic-period/list',
  );
}
/** 查询学段类型详情 */
export function getAcademicPeriod(id: number) {
  return requestClient.get<EdubaseAcademicPeriodApi.AcademicPeriod>(
    `/edu/base/academic-period/get?id=${id}`,
  );
}

/** 新增学段类型 */
export function createAcademicPeriod(
  data: EdubaseAcademicPeriodApi.AcademicPeriod,
) {
  return requestClient.post('/edu/base/academic-period/create', data);
}

/** 修改学段类型 */
export function updateAcademicPeriod(
  data: EdubaseAcademicPeriodApi.AcademicPeriod,
) {
  return requestClient.put('/edu/base/academic-period/update', data);
}

/** 删除学段类型 */
export function deleteAcademicPeriod(id: number) {
  return requestClient.delete(`/edu/base/academic-period/delete?id=${id}`);
}

/** 批量删除学段类型 */
export function deleteAcademicPeriodList(ids: number[]) {
  return requestClient.delete(
    `/edu/base/academic-period/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出学段类型 */
export function exportAcademicPeriod(params: any) {
  return requestClient.download('/edu/base/academic-period/export-excel', {
    params,
  });
}
